<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>QxOrm: C:/Dvlp/_Perso/QxOrm/include/QxDao/QxRepository/QxRepository.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  <td id="projectlogo"><img alt="Logo" src="logo_qxorm.png"/></td>
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">QxOrm
   &#160;<span id="projectnumber">1.4.3</span>
   </div>
   <div id="projectbrief">C++ Object Relational Mapping library</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('_qx_repository_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">QxRepository.h</div>  </div>
</div>
<div class="contents">
<a href="_qx_repository_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/****************************************************************************</span>
<a name="l00002"></a>00002 <span class="comment">**</span>
<a name="l00003"></a>00003 <span class="comment">** http://www.qxorm.com/</span>
<a name="l00004"></a>00004 <span class="comment">** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)</span>
<a name="l00005"></a>00005 <span class="comment">**</span>
<a name="l00006"></a>00006 <span class="comment">** This file is part of the QxOrm library</span>
<a name="l00007"></a>00007 <span class="comment">**</span>
<a name="l00008"></a>00008 <span class="comment">** This software is provided &#39;as-is&#39;, without any express or implied</span>
<a name="l00009"></a>00009 <span class="comment">** warranty. In no event will the authors be held liable for any</span>
<a name="l00010"></a>00010 <span class="comment">** damages arising from the use of this software</span>
<a name="l00011"></a>00011 <span class="comment">**</span>
<a name="l00012"></a>00012 <span class="comment">** Commercial Usage</span>
<a name="l00013"></a>00013 <span class="comment">** Licensees holding valid commercial QxOrm licenses may use this file in</span>
<a name="l00014"></a>00014 <span class="comment">** accordance with the commercial license agreement provided with the</span>
<a name="l00015"></a>00015 <span class="comment">** Software or, alternatively, in accordance with the terms contained in</span>
<a name="l00016"></a>00016 <span class="comment">** a written agreement between you and Lionel Marty</span>
<a name="l00017"></a>00017 <span class="comment">**</span>
<a name="l00018"></a>00018 <span class="comment">** GNU General Public License Usage</span>
<a name="l00019"></a>00019 <span class="comment">** Alternatively, this file may be used under the terms of the GNU</span>
<a name="l00020"></a>00020 <span class="comment">** General Public License version 3.0 as published by the Free Software</span>
<a name="l00021"></a>00021 <span class="comment">** Foundation and appearing in the file &#39;license.gpl3.txt&#39; included in the</span>
<a name="l00022"></a>00022 <span class="comment">** packaging of this file. Please review the following information to</span>
<a name="l00023"></a>00023 <span class="comment">** ensure the GNU General Public License version 3.0 requirements will be</span>
<a name="l00024"></a>00024 <span class="comment">** met : http://www.gnu.org/copyleft/gpl.html</span>
<a name="l00025"></a>00025 <span class="comment">**</span>
<a name="l00026"></a>00026 <span class="comment">** If you are unsure which license is appropriate for your use, or</span>
<a name="l00027"></a>00027 <span class="comment">** if you have questions regarding the use of this file, please contact :</span>
<a name="l00028"></a>00028 <span class="comment">** contact@qxorm.com</span>
<a name="l00029"></a>00029 <span class="comment">**</span>
<a name="l00030"></a>00030 <span class="comment">****************************************************************************/</span>
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 <span class="preprocessor">#ifndef _QX_REPOSITORY_H_</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#define _QX_REPOSITORY_H_</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span>
<a name="l00035"></a>00035 <span class="preprocessor">#ifdef _MSC_VER</span>
<a name="l00036"></a>00036 <span class="preprocessor"></span><span class="preprocessor">#pragma once</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00038"></a>00038 <span class="preprocessor"></span>
<a name="l00046"></a>00046 <span class="preprocessor">#include &lt;boost/type_traits/is_base_of.hpp&gt;</span>
<a name="l00047"></a>00047 
<a name="l00048"></a>00048 <span class="preprocessor">#include &lt;<a class="code" href="_ix_repository_8h.html" title="Common interface for all repositories to provide access to database by introspection using QObject cl...">QxDao/QxRepository/IxRepository.h</a>&gt;</span>
<a name="l00049"></a>00049 <span class="preprocessor">#include &lt;<a class="code" href="_qx_repository_x_8h.html" title="List of all repositories registered using qx::register_repository&lt;T&gt; function.">QxDao/QxRepository/QxRepositoryX.h</a>&gt;</span>
<a name="l00050"></a>00050 
<a name="l00051"></a>00051 <span class="preprocessor">#include &lt;<a class="code" href="_qx_dao_8h.html" title="Provide template functions to map C++ class registered into QxOrm context with table database (ORM - ...">QxDao/QxDao.h</a>&gt;</span>
<a name="l00052"></a>00052 <span class="preprocessor">#include &lt;<a class="code" href="_qx_session_8h.html" title="Define a session to manage automatically database transactions (using C++ RAII)">QxDao/QxSession.h</a>&gt;</span>
<a name="l00053"></a>00053 <span class="preprocessor">#include &lt;<a class="code" href="_qx_sql_error_8h.html" title="Define a SQL error exception and retrieve QSqlError type of Qt library.">QxDao/QxSqlError.h</a>&gt;</span>
<a name="l00054"></a>00054 
<a name="l00055"></a>00055 <span class="preprocessor">#include &lt;<a class="code" href="_qx_class_8h.html" title="Concrete class registered into QxOrm context.">QxRegister/QxClass.h</a>&gt;</span>
<a name="l00056"></a>00056 
<a name="l00057"></a>00057 <span class="preprocessor">#include &lt;<a class="code" href="_qx_collection_8h.html" title="QxOrm container (keep insertion order + quick access by index + quick access by key)">QxCollection/QxCollection.h</a>&gt;</span>
<a name="l00058"></a>00058 
<a name="l00059"></a>00059 <span class="preprocessor">#include &lt;<a class="code" href="get__primary__key_8h.html" title="qx::trait::get_primary_key&lt;T&gt;::type : return primary key type of T, by default primary key is long ty...">QxTraits/get_primary_key.h</a>&gt;</span>
<a name="l00060"></a>00060 
<a name="l00061"></a><a class="code" href="_qx_repository_8h.html#a66f071e9ac3d10bc7da62d6b391c86df">00061</a> <span class="preprocessor">#define QX_REPOSITORY_COLLECTION_DYNAMIC_CAST_ERROR   QSqlError(&quot;[QxOrm] qx::QxRepository&lt;T&gt; : &#39;invalid collection pointer, dynamic_cast failed&#39;&quot;, &quot;&quot;, QSqlError::UnknownError)</span>
<a name="l00062"></a><a class="code" href="_qx_repository_8h.html#af52e6f9587a7121705a3be3e5425bb27">00062</a> <span class="preprocessor"></span><span class="preprocessor">#define QX_REPOSITORY_POINTER_DYNAMIC_CAST_ERROR      QSqlError(&quot;[QxOrm] qx::QxRepository&lt;T&gt; : &#39;invalid pointer, dynamic_cast failed&#39;&quot;, &quot;&quot;, QSqlError::UnknownError)</span>
<a name="l00063"></a><a class="code" href="_qx_repository_8h.html#abfc04341b91ebd0997235f9f5c5b754c">00063</a> <span class="preprocessor"></span><span class="preprocessor">#define QX_REPOSITORY_QOBJECT_BASE_CLASS_ERROR        QSqlError(&quot;[QxOrm] qx::QxRepository&lt;T&gt; : &#39;invalid pointer, need to inherit from QObject class to use qx::IxRepository interface&#39;&quot;, &quot;&quot;, QSqlError::UnknownError)</span>
<a name="l00064"></a>00064 <span class="preprocessor"></span>
<a name="l00065"></a>00065 <span class="preprocessor">#ifndef _QX_NO_RTTI</span>
<a name="l00066"></a><a class="code" href="_qx_repository_8h.html#a09101357f58266c835562c64dc380ddd">00066</a> <span class="preprocessor"></span><span class="preprocessor">#define QX_REPOSITORY_CAST_COLLECTION \</span>
<a name="l00067"></a>00067 <span class="preprocessor">type_collection_qt * x = dynamic_cast&lt;type_collection_qt *&gt;(p); \</span>
<a name="l00068"></a>00068 <span class="preprocessor">type_collection_boost * y = (x ? NULL : dynamic_cast&lt;type_collection_boost *&gt;(p)); \</span>
<a name="l00069"></a>00069 <span class="preprocessor">if (! x &amp;&amp; ! y) { throw qx::dao::sql_error(QX_REPOSITORY_COLLECTION_DYNAMIC_CAST_ERROR); }</span>
<a name="l00070"></a>00070 <span class="preprocessor"></span><span class="preprocessor">#else // _QX_NO_RTTI</span>
<a name="l00071"></a>00071 <span class="preprocessor"></span><span class="preprocessor">#define QX_REPOSITORY_CAST_COLLECTION \</span>
<a name="l00072"></a>00072 <span class="preprocessor">type_collection_qt * x = NULL; \</span>
<a name="l00073"></a>00073 <span class="preprocessor">type_collection_boost * y = static_cast&lt;type_collection_boost *&gt;(p);</span>
<a name="l00074"></a>00074 <span class="preprocessor"></span><span class="preprocessor">#endif // _QX_NO_RTTI</span>
<a name="l00075"></a>00075 <span class="preprocessor"></span>
<a name="l00076"></a>00076 <span class="keyword">namespace </span>qx {
<a name="l00077"></a>00077 
<a name="l00078"></a>00078 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
<a name="l00079"></a>00079 <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="namespaceqx.html#a10d662c78d56271d8fdaeff896548e46">register_repository</a>(<span class="keyword">const</span> QString &amp; sKey);
<a name="l00080"></a>00080 
<a name="l00085"></a>00085 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
<a name="l00086"></a><a class="code" href="classqx_1_1_qx_repository.html">00086</a> <span class="keyword">class </span><a class="code" href="classqx_1_1_qx_repository.html" title="qx::QxRepository&lt;T&gt; : repository to provide a common interface to communicate with database...">QxRepository</a> : <span class="keyword">public</span> <a class="code" href="classqx_1_1_ix_repository.html" title="qx::IxRepository : common interface for all repositories to provide access to database by introspecti...">IxRepository</a>
<a name="l00087"></a>00087 {
<a name="l00088"></a>00088 
<a name="l00089"></a>00089    <span class="keyword">template</span> &lt;<span class="keyword">class</span> U&gt;
<a name="l00090"></a>00090    <span class="keyword">friend</span> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="classqx_1_1_qx_repository.html#a5515eb786d85e1fcf70ba037e65163b7">register_repository</a>(<span class="keyword">const</span> QString &amp; sKey);
<a name="l00091"></a>00091 
<a name="l00092"></a>00092 <span class="keyword">private</span>:
<a name="l00093"></a>00093 
<a name="l00094"></a><a class="code" href="classqx_1_1_qx_repository.html#a0f802ca83ccaa309a3fa6b548e726a4d">00094</a>    <a class="code" href="classqx_1_1_qx_repository.html#a0f802ca83ccaa309a3fa6b548e726a4d">QxRepository</a>(<span class="keyword">const</span> QString &amp; sKey) : <a class="code" href="classqx_1_1_ix_repository.html" title="qx::IxRepository : common interface for all repositories to provide access to database by introspecti...">IxRepository</a>(true, sKey) { ; }
<a name="l00095"></a>00095 
<a name="l00096"></a>00096 <span class="keyword">public</span>:
<a name="l00097"></a>00097 
<a name="l00098"></a><a class="code" href="classqx_1_1_qx_repository.html#a3cc812869b0645a789e5c3b5ee4b5b70">00098</a>    <a class="code" href="classqx_1_1_qx_repository.html#a3cc812869b0645a789e5c3b5ee4b5b70">QxRepository</a>() : <a class="code" href="classqx_1_1_ix_repository.html" title="qx::IxRepository : common interface for all repositories to provide access to database by introspecti...">IxRepository</a>(false, QString(<span class="stringliteral">&quot;&quot;</span>)) { ; }
<a name="l00099"></a><a class="code" href="classqx_1_1_qx_repository.html#a9d5a0e083502b4f1382779d8aa087c40">00099</a>    <a class="code" href="classqx_1_1_qx_repository.html#a9d5a0e083502b4f1382779d8aa087c40">QxRepository</a>(<span class="keyword">const</span> QSqlDatabase &amp; <a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>) : <a class="code" href="classqx_1_1_ix_repository.html" title="qx::IxRepository : common interface for all repositories to provide access to database by introspecti...">IxRepository</a>(false, QString(<span class="stringliteral">&quot;&quot;</span>), database) { ; }
<a name="l00100"></a><a class="code" href="classqx_1_1_qx_repository.html#a6b6ce13984e70985cbf1dd1dce5fce76">00100</a>    <a class="code" href="classqx_1_1_qx_repository.html#a6b6ce13984e70985cbf1dd1dce5fce76">QxRepository</a>(<a class="code" href="classqx_1_1_qx_session.html" title="qx::QxSession : define a session to manage automatically database transactions (using C++ RAII)...">QxSession</a> * pSession) : <a class="code" href="classqx_1_1_ix_repository.html" title="qx::IxRepository : common interface for all repositories to provide access to database by introspecti...">IxRepository</a>(false, QString(<span class="stringliteral">&quot;&quot;</span>), pSession) { ; }
<a name="l00101"></a><a class="code" href="classqx_1_1_qx_repository.html#aad030853a96cbec6dbe6c26c8abff0d4">00101</a>    <span class="keyword">virtual</span> <a class="code" href="classqx_1_1_qx_repository.html#aad030853a96cbec6dbe6c26c8abff0d4">~QxRepository</a>() { ; }
<a name="l00102"></a>00102 
<a name="l00103"></a><a class="code" href="classqx_1_1_qx_repository.html#aaeaf116e22bb483dee412fa844688bfe">00103</a>    <span class="keywordtype">long</span> <a class="code" href="classqx_1_1_qx_repository.html#aaeaf116e22bb483dee412fa844688bfe">count</a>(<span class="keyword">const</span> <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a> &amp; query = <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a>())
<a name="l00104"></a>00104    { <span class="keywordflow">return</span> qx::dao::count&lt;T&gt;(query, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>()); }
<a name="l00105"></a>00105 
<a name="l00106"></a><a class="code" href="classqx_1_1_qx_repository.html#a2a606e996bfa58f5d1af7e62104622ac">00106</a>    T * <a class="code" href="classqx_1_1_qx_repository.html#a2a606e996bfa58f5d1af7e62104622ac">fetchById</a>(<span class="keyword">const</span> QVariant &amp; <span class="keywordtype">id</span>, <span class="keyword">const</span> QStringList &amp; columns = QStringList(), <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00107"></a>00107    {
<a name="l00108"></a>00108       <a class="code" href="classqx_1_1_ix_data_member_x.html" title="qx::IxDataMemberX : common interface for a list of IxDataMember class properties registered into QxOr...">IxDataMemberX</a> * pDataMemberX = <a class="code" href="classqx_1_1_qx_class.html" title="qx::QxClass&lt;T&gt; : concrete class of type T registered into QxOrm context (this class is a singleton an...">QxClass&lt;T&gt;::getSingleton</a>()-&gt;<a class="code" href="classqx_1_1_ix_class.html#a668a6091e56a8133606e64cba430baa4">getDataMemberX</a>();
<a name="l00109"></a>00109       <a class="code" href="classqx_1_1_ix_data_member.html" title="qx::IxDataMember : common interface for all class properties registered into QxOrm context...">IxDataMember</a> * pDataMemberId = (pDataMemberX ? pDataMemberX-&gt;<a class="code" href="classqx_1_1_ix_data_member_x.html#ada28538e61c5fd9bf352abdb325be6b0">getId_WithDaoStrategy</a>() : NULL);
<a name="l00110"></a>00110       <span class="keywordflow">if</span> (! pDataMemberId) { <a class="code" href="_qx_macro_8h.html#a70ab6c4ed8eb3e23107f171e0b41d612">qAssert</a>(<span class="keyword">false</span>); <span class="keywordflow">return</span> NULL; }
<a name="l00111"></a>00111       T * t = <span class="keyword">new</span> T(); QSqlError err;
<a name="l00112"></a>00112       pDataMemberId-&gt;<a class="code" href="classqx_1_1_ix_data_member.html#ab745b2a043797eecfe769c3f51257a35">fromVariant</a>(t, <span class="keywordtype">id</span>, -1, <a class="code" href="structqx_1_1cvt_1_1context.html#ade79c85929462745a3adcdf310c91a93a5fe28c5356333a6d2633c93cbd6e48e5">qx::cvt::context::e_database</a>);
<a name="l00113"></a>00113       <span class="keywordflow">if</span> (relation.count() == 0) { err = <a class="code" href="group___qx_dao.html#ga2abaf5f2e6de160b099cf2ab74967244" title="Fetch an object t (retrieve all its properties) of type T (registered into QxOrm context) mapped to a...">qx::dao::fetch_by_id</a>((* t), this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>(), columns); }
<a name="l00114"></a>00114       <span class="keywordflow">else</span> { err = <a class="code" href="group___qx_dao.html#ga37648a23475371e1b83ea2082265790d" title="Fetch an object t (retrieve all its properties) of type T (registered into QxOrm context) mapped to a...">qx::dao::fetch_by_id_with_relation</a>(relation, (* t), this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>()); }
<a name="l00115"></a>00115       <span class="keywordflow">if</span> (err.isValid() &amp;&amp; <a class="code" href="classqx_1_1_ix_repository.html#aa9c2b2ae5df27aedbe5eeb5a1dd3d23c" title="Session associated to the repository.">m_pSession</a>) { <span class="keyword">delete</span> t; t = NULL; (* m_pSession) += err; }
<a name="l00116"></a>00116       <span class="keywordflow">else</span> <span class="keywordflow">if</span> (err.isValid()) { <span class="keyword">delete</span> t; t = NULL; }
<a name="l00117"></a>00117       <span class="keywordflow">return</span> t;
<a name="l00118"></a>00118    }
<a name="l00119"></a>00119 
<a name="l00120"></a>00120    <span class="keyword">template</span> &lt;<span class="keyword">class</span> U&gt;
<a name="l00121"></a><a class="code" href="classqx_1_1_qx_repository.html#ac4737ba4c75fde6919ab253315497068">00121</a>    QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a2a606e996bfa58f5d1af7e62104622ac">fetchById</a>(U &amp; u, <span class="keyword">const</span> QStringList &amp; columns = QStringList(), <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00122"></a>00122    {
<a name="l00123"></a>00123       QSqlError err;
<a name="l00124"></a>00124       <span class="keywordflow">if</span> (relation.count() == 0) { err = <a class="code" href="group___qx_dao.html#ga2abaf5f2e6de160b099cf2ab74967244" title="Fetch an object t (retrieve all its properties) of type T (registered into QxOrm context) mapped to a...">qx::dao::fetch_by_id</a>(u, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>(), columns); }
<a name="l00125"></a>00125       <span class="keywordflow">else</span> { err = <a class="code" href="group___qx_dao.html#ga37648a23475371e1b83ea2082265790d" title="Fetch an object t (retrieve all its properties) of type T (registered into QxOrm context) mapped to a...">qx::dao::fetch_by_id_with_relation</a>(relation, u, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>()); }
<a name="l00126"></a>00126       <span class="keywordflow">if</span> (err.isValid() &amp;&amp; <a class="code" href="classqx_1_1_ix_repository.html#aa9c2b2ae5df27aedbe5eeb5a1dd3d23c" title="Session associated to the repository.">m_pSession</a>) { (* m_pSession) += err; }
<a name="l00127"></a>00127       <span class="keywordflow">return</span> err;
<a name="l00128"></a>00128    }
<a name="l00129"></a>00129 
<a name="l00130"></a>00130    <span class="keyword">template</span> &lt;<span class="keyword">class</span> U&gt;
<a name="l00131"></a><a class="code" href="classqx_1_1_qx_repository.html#aefbdf94ee25b218ae2a5cbc21977cf32">00131</a>    QSqlError <a class="code" href="classqx_1_1_qx_repository.html#aefbdf94ee25b218ae2a5cbc21977cf32">fetchAll</a>(U &amp; u, <span class="keyword">const</span> QStringList &amp; columns = QStringList(), <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00132"></a>00132    {
<a name="l00133"></a>00133       QSqlError err;
<a name="l00134"></a>00134       <span class="keywordflow">if</span> (relation.count() == 0) { err = <a class="code" href="group___qx_dao.html#gab7a00918917a06ad703a8d6887b94edb" title="Fetch a list of objects (retrieve all elements and properties associated) of type T (container regist...">qx::dao::fetch_all</a>(u, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>(), columns); }
<a name="l00135"></a>00135       <span class="keywordflow">else</span> { err = <a class="code" href="group___qx_dao.html#gad4e90031bacdd06cf278ae3ccefa9811" title="Fetch a list of objects (retrieve all elements and properties associated) of type T (container regist...">qx::dao::fetch_all_with_relation</a>(relation, u, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>()); }
<a name="l00136"></a>00136       <span class="keywordflow">if</span> (err.isValid() &amp;&amp; <a class="code" href="classqx_1_1_ix_repository.html#aa9c2b2ae5df27aedbe5eeb5a1dd3d23c" title="Session associated to the repository.">m_pSession</a>) { (* m_pSession) += err; }
<a name="l00137"></a>00137       <span class="keywordflow">return</span> err;
<a name="l00138"></a>00138    }
<a name="l00139"></a>00139 
<a name="l00140"></a>00140    <span class="keyword">template</span> &lt;<span class="keyword">class</span> U&gt;
<a name="l00141"></a><a class="code" href="classqx_1_1_qx_repository.html#a887d3f3f555fca6d41442cc18fa786a9">00141</a>    QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a887d3f3f555fca6d41442cc18fa786a9">fetchByQuery</a>(<span class="keyword">const</span> <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a> &amp; query, U &amp; u, <span class="keyword">const</span> QStringList &amp; columns = QStringList(), <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00142"></a>00142    {
<a name="l00143"></a>00143       QSqlError err;
<a name="l00144"></a>00144       <span class="keywordflow">if</span> (relation.count() == 0) { err = <a class="code" href="group___qx_dao.html#ga98785915863d9487b0f3734b667a3c72" title="Fetch a list of objects (retrieve all elements and properties associated) of type T (container regist...">qx::dao::fetch_by_query</a>(query, u, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>(), columns); }
<a name="l00145"></a>00145       <span class="keywordflow">else</span> { err = <a class="code" href="group___qx_dao.html#ga2d8f0176ef1c7b675297637090c95129" title="Fetch a list of objects (retrieve all elements and properties associated) of type T (container regist...">qx::dao::fetch_by_query_with_relation</a>(relation, query, u, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>()); }
<a name="l00146"></a>00146       <span class="keywordflow">if</span> (err.isValid() &amp;&amp; <a class="code" href="classqx_1_1_ix_repository.html#aa9c2b2ae5df27aedbe5eeb5a1dd3d23c" title="Session associated to the repository.">m_pSession</a>) { (* m_pSession) += err; }
<a name="l00147"></a>00147       <span class="keywordflow">return</span> err;
<a name="l00148"></a>00148    }
<a name="l00149"></a>00149 
<a name="l00150"></a>00150    <span class="keyword">template</span> &lt;<span class="keyword">class</span> U&gt;
<a name="l00151"></a><a class="code" href="classqx_1_1_qx_repository.html#ad2a39526df52bb5b02fc54f4d24798c7">00151</a>    QSqlError <a class="code" href="classqx_1_1_qx_repository.html#ad2a39526df52bb5b02fc54f4d24798c7">insert</a>(U &amp; u, <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00152"></a>00152    {
<a name="l00153"></a>00153       QSqlError err;
<a name="l00154"></a>00154       <span class="keywordflow">if</span> (relation.count() == 0) { err = <a class="code" href="classqx_1_1_qx_repository.html#ad2a39526df52bb5b02fc54f4d24798c7">qx::dao::insert</a>(u, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>()); }
<a name="l00155"></a>00155       <span class="keywordflow">else</span> { err = <a class="code" href="group___qx_dao.html#ga82e03bc10e1fbdc3f58f1efac252f4bc" title="Insert an element and its relationships (or a list of elements + relationships) into database...">qx::dao::insert_with_relation</a>(relation, u, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>()); }
<a name="l00156"></a>00156       <span class="keywordflow">if</span> (err.isValid() &amp;&amp; <a class="code" href="classqx_1_1_ix_repository.html#aa9c2b2ae5df27aedbe5eeb5a1dd3d23c" title="Session associated to the repository.">m_pSession</a>) { (* m_pSession) += err; }
<a name="l00157"></a>00157       <span class="keywordflow">return</span> err;
<a name="l00158"></a>00158    }
<a name="l00159"></a>00159 
<a name="l00160"></a>00160    <span class="keyword">template</span> &lt;<span class="keyword">class</span> U&gt;
<a name="l00161"></a><a class="code" href="classqx_1_1_qx_repository.html#a76aef40c870df4484a67e75134ea6aa0">00161</a>    QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a76aef40c870df4484a67e75134ea6aa0">update</a>(U &amp; u, <span class="keyword">const</span> <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a> &amp; query = <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a>(), <span class="keyword">const</span> QStringList &amp; columns = QStringList(), <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00162"></a>00162    {
<a name="l00163"></a>00163       QSqlError err;
<a name="l00164"></a>00164       <span class="keywordflow">if</span> (relation.count() == 0) { err = <a class="code" href="group___qx_dao.html#ga1bd1d32eccfb73ccd6a0e82130061fb4" title="Update an element or a list of elements into database (adding a user SQL query to the default SQL que...">qx::dao::update_by_query</a>(query, u, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>(), columns); }
<a name="l00165"></a>00165       <span class="keywordflow">else</span> { err = <a class="code" href="group___qx_dao.html#ga9fb34aec7e865b97365c91ba20e422d2" title="Update an element and its relationships (or a list of elements + relationships) into database (adding...">qx::dao::update_by_query_with_relation</a>(relation, query, u, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>()); }
<a name="l00166"></a>00166       <span class="keywordflow">if</span> (err.isValid() &amp;&amp; <a class="code" href="classqx_1_1_ix_repository.html#aa9c2b2ae5df27aedbe5eeb5a1dd3d23c" title="Session associated to the repository.">m_pSession</a>) { (* m_pSession) += err; }
<a name="l00167"></a>00167       <span class="keywordflow">return</span> err;
<a name="l00168"></a>00168    }
<a name="l00169"></a>00169 
<a name="l00170"></a>00170    <span class="keyword">template</span> &lt;<span class="keyword">class</span> U&gt;
<a name="l00171"></a><a class="code" href="classqx_1_1_qx_repository.html#a85189ede9577d00a21a51b48c2bc5f7c">00171</a>    QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a85189ede9577d00a21a51b48c2bc5f7c">save</a>(U &amp; u, <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00172"></a>00172    {
<a name="l00173"></a>00173       QSqlError err;
<a name="l00174"></a>00174       <span class="keywordflow">if</span> (relation.count() == 0) { err = <a class="code" href="classqx_1_1_qx_repository.html#a85189ede9577d00a21a51b48c2bc5f7c">qx::dao::save</a>(u, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>()); }
<a name="l00175"></a>00175       <span class="keywordflow">else</span> { err = <a class="code" href="group___qx_dao.html#ga653fbb3a886e48bca4236ea3fe6ac865" title="Insert (if no exist) or update (if already exist) an element and its relationships (or a list of elem...">qx::dao::save_with_relation</a>(relation, u, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>()); }
<a name="l00176"></a>00176       <span class="keywordflow">if</span> (err.isValid() &amp;&amp; <a class="code" href="classqx_1_1_ix_repository.html#aa9c2b2ae5df27aedbe5eeb5a1dd3d23c" title="Session associated to the repository.">m_pSession</a>) { (* m_pSession) += err; }
<a name="l00177"></a>00177       <span class="keywordflow">return</span> err;
<a name="l00178"></a>00178    }
<a name="l00179"></a>00179 
<a name="l00180"></a><a class="code" href="classqx_1_1_qx_repository.html#a310fbb3908beebff59e61cc5dd5b92fa">00180</a>    QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a310fbb3908beebff59e61cc5dd5b92fa">deleteById</a>(<span class="keyword">const</span> QVariant &amp; <span class="keywordtype">id</span>)
<a name="l00181"></a>00181    {
<a name="l00182"></a>00182       <a class="code" href="classqx_1_1_ix_data_member_x.html" title="qx::IxDataMemberX : common interface for a list of IxDataMember class properties registered into QxOr...">IxDataMemberX</a> * pDataMemberX = <a class="code" href="classqx_1_1_qx_class.html" title="qx::QxClass&lt;T&gt; : concrete class of type T registered into QxOrm context (this class is a singleton an...">QxClass&lt;T&gt;::getSingleton</a>()-&gt;<a class="code" href="classqx_1_1_ix_class.html#a668a6091e56a8133606e64cba430baa4">getDataMemberX</a>();
<a name="l00183"></a>00183       <a class="code" href="classqx_1_1_ix_data_member.html" title="qx::IxDataMember : common interface for all class properties registered into QxOrm context...">IxDataMember</a> * pDataMemberId = (pDataMemberX ? pDataMemberX-&gt;<a class="code" href="classqx_1_1_ix_data_member_x.html#ada28538e61c5fd9bf352abdb325be6b0">getId_WithDaoStrategy</a>() : NULL);
<a name="l00184"></a>00184       <span class="keywordflow">if</span> (! pDataMemberId) { <a class="code" href="_qx_macro_8h.html#a70ab6c4ed8eb3e23107f171e0b41d612">qAssert</a>(<span class="keyword">false</span>); <span class="keywordflow">return</span> QSqlError(); }
<a name="l00185"></a>00185       qx_shared_ptr&lt;T&gt; t; t.reset(<span class="keyword">new</span> T());
<a name="l00186"></a>00186       pDataMemberId-&gt;<a class="code" href="classqx_1_1_ix_data_member.html#ab745b2a043797eecfe769c3f51257a35">fromVariant</a>(t.get(), id, -1, <a class="code" href="structqx_1_1cvt_1_1context.html#ade79c85929462745a3adcdf310c91a93a5fe28c5356333a6d2633c93cbd6e48e5">qx::cvt::context::e_database</a>);
<a name="l00187"></a>00187       QSqlError err = <a class="code" href="group___qx_dao.html#ga298e15a5e745ae43d99de9b4279aca3e" title="Delete a line (or list of lines) of a table (database) mapped to a C++ object of type T (registered i...">qx::dao::delete_by_id</a>((* t), this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>());
<a name="l00188"></a>00188       <span class="keywordflow">if</span> (err.isValid() &amp;&amp; <a class="code" href="classqx_1_1_ix_repository.html#aa9c2b2ae5df27aedbe5eeb5a1dd3d23c" title="Session associated to the repository.">m_pSession</a>) { (* m_pSession) += err; }
<a name="l00189"></a>00189       <span class="keywordflow">return</span> err;
<a name="l00190"></a>00190    }
<a name="l00191"></a>00191 
<a name="l00192"></a>00192    <span class="keyword">template</span> &lt;<span class="keyword">class</span> U&gt;
<a name="l00193"></a><a class="code" href="classqx_1_1_qx_repository.html#ae4d8942c11983a1715beb53d1f2136c3">00193</a>    QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a310fbb3908beebff59e61cc5dd5b92fa">deleteById</a>(U &amp; u)
<a name="l00194"></a>00194    {
<a name="l00195"></a>00195       QSqlError err = <a class="code" href="group___qx_dao.html#ga298e15a5e745ae43d99de9b4279aca3e" title="Delete a line (or list of lines) of a table (database) mapped to a C++ object of type T (registered i...">qx::dao::delete_by_id</a>(u, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>());
<a name="l00196"></a>00196       <span class="keywordflow">if</span> (err.isValid() &amp;&amp; <a class="code" href="classqx_1_1_ix_repository.html#aa9c2b2ae5df27aedbe5eeb5a1dd3d23c" title="Session associated to the repository.">m_pSession</a>) { (* m_pSession) += err; }
<a name="l00197"></a>00197       <span class="keywordflow">return</span> err;
<a name="l00198"></a>00198    }
<a name="l00199"></a>00199 
<a name="l00200"></a><a class="code" href="classqx_1_1_qx_repository.html#af4af3fb73fa2d10ff47cc21d6a755e5b">00200</a>    QSqlError <a class="code" href="classqx_1_1_qx_repository.html#af4af3fb73fa2d10ff47cc21d6a755e5b">deleteAll</a>()
<a name="l00201"></a>00201    {
<a name="l00202"></a>00202       QSqlError err = qx::dao::delete_all&lt;T&gt;(this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>());
<a name="l00203"></a>00203       <span class="keywordflow">if</span> (err.isValid() &amp;&amp; <a class="code" href="classqx_1_1_ix_repository.html#aa9c2b2ae5df27aedbe5eeb5a1dd3d23c" title="Session associated to the repository.">m_pSession</a>) { (* m_pSession) += err; }
<a name="l00204"></a>00204       <span class="keywordflow">return</span> err;
<a name="l00205"></a>00205    }
<a name="l00206"></a>00206 
<a name="l00207"></a><a class="code" href="classqx_1_1_qx_repository.html#a5f8d83b11586eb7235601fc24905addb">00207</a>    QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a5f8d83b11586eb7235601fc24905addb">deleteByQuery</a>(<span class="keyword">const</span> <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a> &amp; query)
<a name="l00208"></a>00208    {
<a name="l00209"></a>00209       QSqlError err = qx::dao::delete_by_query&lt;T&gt;(query, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>());
<a name="l00210"></a>00210       <span class="keywordflow">if</span> (err.isValid() &amp;&amp; <a class="code" href="classqx_1_1_ix_repository.html#aa9c2b2ae5df27aedbe5eeb5a1dd3d23c" title="Session associated to the repository.">m_pSession</a>) { (* m_pSession) += err; }
<a name="l00211"></a>00211       <span class="keywordflow">return</span> err;
<a name="l00212"></a>00212    }
<a name="l00213"></a>00213 
<a name="l00214"></a><a class="code" href="classqx_1_1_qx_repository.html#aa841e88f363fe8e6247d750727e8b89d">00214</a>    QSqlError <a class="code" href="classqx_1_1_qx_repository.html#aa841e88f363fe8e6247d750727e8b89d">destroyById</a>(<span class="keyword">const</span> QVariant &amp; <span class="keywordtype">id</span>)
<a name="l00215"></a>00215    {
<a name="l00216"></a>00216       <a class="code" href="classqx_1_1_ix_data_member_x.html" title="qx::IxDataMemberX : common interface for a list of IxDataMember class properties registered into QxOr...">IxDataMemberX</a> * pDataMemberX = <a class="code" href="classqx_1_1_qx_class.html" title="qx::QxClass&lt;T&gt; : concrete class of type T registered into QxOrm context (this class is a singleton an...">QxClass&lt;T&gt;::getSingleton</a>()-&gt;<a class="code" href="classqx_1_1_ix_class.html#a668a6091e56a8133606e64cba430baa4">getDataMemberX</a>();
<a name="l00217"></a>00217       <a class="code" href="classqx_1_1_ix_data_member.html" title="qx::IxDataMember : common interface for all class properties registered into QxOrm context...">IxDataMember</a> * pDataMemberId = (pDataMemberX ? pDataMemberX-&gt;<a class="code" href="classqx_1_1_ix_data_member_x.html#ada28538e61c5fd9bf352abdb325be6b0">getId_WithDaoStrategy</a>() : NULL);
<a name="l00218"></a>00218       <span class="keywordflow">if</span> (! pDataMemberId) { <a class="code" href="_qx_macro_8h.html#a70ab6c4ed8eb3e23107f171e0b41d612">qAssert</a>(<span class="keyword">false</span>); <span class="keywordflow">return</span> QSqlError(); }
<a name="l00219"></a>00219       qx_shared_ptr&lt;T&gt; t; t.reset(<span class="keyword">new</span> T());
<a name="l00220"></a>00220       pDataMemberId-&gt;<a class="code" href="classqx_1_1_ix_data_member.html#ab745b2a043797eecfe769c3f51257a35">fromVariant</a>(t.get(), id, -1, <a class="code" href="structqx_1_1cvt_1_1context.html#ade79c85929462745a3adcdf310c91a93a5fe28c5356333a6d2633c93cbd6e48e5">qx::cvt::context::e_database</a>);
<a name="l00221"></a>00221       QSqlError err = <a class="code" href="group___qx_dao.html#ga776e2edd2da36029cddc13e9e6e366f5" title="Destroy a line (or list of lines) of a table (database) mapped to a C++ object of type T (registered ...">qx::dao::destroy_by_id</a>((* t), this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>());
<a name="l00222"></a>00222       <span class="keywordflow">if</span> (err.isValid() &amp;&amp; <a class="code" href="classqx_1_1_ix_repository.html#aa9c2b2ae5df27aedbe5eeb5a1dd3d23c" title="Session associated to the repository.">m_pSession</a>) { (* m_pSession) += err; }
<a name="l00223"></a>00223       <span class="keywordflow">return</span> err;
<a name="l00224"></a>00224    }
<a name="l00225"></a>00225 
<a name="l00226"></a>00226    <span class="keyword">template</span> &lt;<span class="keyword">class</span> U&gt;
<a name="l00227"></a><a class="code" href="classqx_1_1_qx_repository.html#a722653079eb088d6903393e3c83c4ef4">00227</a>    QSqlError <a class="code" href="classqx_1_1_qx_repository.html#aa841e88f363fe8e6247d750727e8b89d">destroyById</a>(U &amp; u)
<a name="l00228"></a>00228    {
<a name="l00229"></a>00229       QSqlError err = <a class="code" href="group___qx_dao.html#ga776e2edd2da36029cddc13e9e6e366f5" title="Destroy a line (or list of lines) of a table (database) mapped to a C++ object of type T (registered ...">qx::dao::destroy_by_id</a>(u, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>());
<a name="l00230"></a>00230       <span class="keywordflow">if</span> (err.isValid() &amp;&amp; <a class="code" href="classqx_1_1_ix_repository.html#aa9c2b2ae5df27aedbe5eeb5a1dd3d23c" title="Session associated to the repository.">m_pSession</a>) { (* m_pSession) += err; }
<a name="l00231"></a>00231       <span class="keywordflow">return</span> err;
<a name="l00232"></a>00232    }
<a name="l00233"></a>00233 
<a name="l00234"></a><a class="code" href="classqx_1_1_qx_repository.html#a7e1b18e3b6aabee7b1978b0bdd8bbe93">00234</a>    QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a7e1b18e3b6aabee7b1978b0bdd8bbe93">destroyAll</a>()
<a name="l00235"></a>00235    {
<a name="l00236"></a>00236       QSqlError err = qx::dao::destroy_all&lt;T&gt;(this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>());
<a name="l00237"></a>00237       <span class="keywordflow">if</span> (err.isValid() &amp;&amp; <a class="code" href="classqx_1_1_ix_repository.html#aa9c2b2ae5df27aedbe5eeb5a1dd3d23c" title="Session associated to the repository.">m_pSession</a>) { (* m_pSession) += err; }
<a name="l00238"></a>00238       <span class="keywordflow">return</span> err;
<a name="l00239"></a>00239    }
<a name="l00240"></a>00240 
<a name="l00241"></a><a class="code" href="classqx_1_1_qx_repository.html#ad19da768437a00d0cc00f0ac4c7d9823">00241</a>    QSqlError <a class="code" href="classqx_1_1_qx_repository.html#ad19da768437a00d0cc00f0ac4c7d9823">destroyByQuery</a>(<span class="keyword">const</span> <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a> &amp; query)
<a name="l00242"></a>00242    {
<a name="l00243"></a>00243       QSqlError err = qx::dao::destroy_by_query&lt;T&gt;(query, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>());
<a name="l00244"></a>00244       <span class="keywordflow">if</span> (err.isValid() &amp;&amp; <a class="code" href="classqx_1_1_ix_repository.html#aa9c2b2ae5df27aedbe5eeb5a1dd3d23c" title="Session associated to the repository.">m_pSession</a>) { (* m_pSession) += err; }
<a name="l00245"></a>00245       <span class="keywordflow">return</span> err;
<a name="l00246"></a>00246    }
<a name="l00247"></a>00247 
<a name="l00248"></a>00248    <span class="keyword">template</span> &lt;<span class="keyword">class</span> U&gt;
<a name="l00249"></a><a class="code" href="classqx_1_1_qx_repository.html#a1bd74ee1ac371e5f0c7903d1534f6864">00249</a>    <a class="code" href="classqx_1_1_qx_bool.html" title="qx_bool : boolean type with code and description message when an error occured">qx_bool</a> <a class="code" href="classqx_1_1_qx_repository.html#a1bd74ee1ac371e5f0c7903d1534f6864">exist</a>(U &amp; u)
<a name="l00250"></a>00250    { <span class="keywordflow">return</span> <a class="code" href="classqx_1_1_qx_repository.html#a1bd74ee1ac371e5f0c7903d1534f6864">qx::dao::exist</a>(u, this-&gt;<a class="code" href="classqx_1_1_ix_repository.html#afe835dcf2cf658f83099adfb5316df09">database</a>()); }
<a name="l00251"></a>00251 
<a name="l00252"></a>00252 <span class="keyword">private</span>:
<a name="l00253"></a>00253 
<a name="l00254"></a><a class="code" href="classqx_1_1_qx_repository.html#a57879f7229748e734ca5f10d7b6b5935">00254</a>    <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="classqx_1_1trait_1_1get__primary__key.html#a11ae75af18e7cc688dd45e73c037dc39">qx::trait::get_primary_key&lt;T&gt;::type</a> <a class="code" href="classqx_1_1_qx_repository.html#a57879f7229748e734ca5f10d7b6b5935">type_primary_key</a>;
<a name="l00255"></a><a class="code" href="classqx_1_1_qx_repository.html#a93794cc58b41ef86e6ba67165aec8542">00255</a>    <span class="keyword">typedef</span> <a class="code" href="classqx_1_1_qx_collection.html" title="qx::QxCollection&lt;Key, Value&gt; : QxOrm container (keep insertion order + quick access by index + quick ...">qx::QxCollection&lt; type_primary_key, QSharedPointer&lt;T&gt;</a> &gt; <a class="code" href="classqx_1_1_qx_repository.html#a93794cc58b41ef86e6ba67165aec8542">type_collection_qt</a>;
<a name="l00256"></a><a class="code" href="classqx_1_1_qx_repository.html#abe161ac26ebe9c7cb4fa02175abf6081">00256</a>    <span class="keyword">typedef</span> <a class="code" href="classqx_1_1_qx_collection.html" title="qx::QxCollection&lt;Key, Value&gt; : QxOrm container (keep insertion order + quick access by index + quick ...">qx::QxCollection&lt; type_primary_key, qx_shared_ptr&lt;T&gt;</a> &gt; <a class="code" href="classqx_1_1_qx_repository.html#abe161ac26ebe9c7cb4fa02175abf6081">type_collection_boost</a>;
<a name="l00257"></a>00257 
<a name="l00258"></a>00258    <span class="keyword">template</span> &lt;<span class="keywordtype">bool</span> bIsQObject <span class="comment">/* = false */</span>, <span class="keywordtype">int</span> dummy&gt;
<a name="l00259"></a><a class="code" href="structqx_1_1_qx_repository_1_1qx_verify_pointer.html">00259</a>    <span class="keyword">struct </span><a class="code" href="structqx_1_1_qx_repository_1_1qx_verify_pointer.html">qxVerifyPointer</a>
<a name="l00260"></a><a class="code" href="structqx_1_1_qx_repository_1_1qx_verify_pointer.html#a96c6ec1a79b6632ca3a6f2b853687a55">00260</a>    { <span class="keyword">static</span> <span class="keyword">inline</span> T * <span class="keyword">get</span>(QObject * p) { Q_UNUSED(p); <span class="keywordflow">throw</span> <a class="code" href="classqx_1_1dao_1_1sql__error.html" title="qx::dao::sql_error : define a SQL error exception and retrieve QSqlError type of Qt library...">qx::dao::sql_error</a>(<a class="code" href="_qx_repository_8h.html#abfc04341b91ebd0997235f9f5c5b754c">QX_REPOSITORY_QOBJECT_BASE_CLASS_ERROR</a>); <span class="keywordflow">return</span> NULL; } };
<a name="l00261"></a>00261 
<a name="l00262"></a>00262    <span class="keyword">template</span> &lt;<span class="keywordtype">int</span> dummy&gt;
<a name="l00263"></a><a class="code" href="structqx_1_1_qx_repository_1_1qx_verify_pointer_3_01true_00_01dummy_01_4.html">00263</a>    <span class="keyword">struct </span><a class="code" href="structqx_1_1_qx_repository_1_1qx_verify_pointer.html">qxVerifyPointer</a>&lt;true, dummy&gt;
<a name="l00264"></a>00264 #ifdef _QX_NO_RTTI
<a name="l00265"></a>00265    { <span class="keyword">static</span> <span class="keyword">inline</span> T * <span class="keyword">get</span>(QObject * p) { T * t = qobject_cast&lt;T *&gt;(p); <span class="keywordflow">if</span> (! t) { <span class="keywordflow">throw</span> <a class="code" href="classqx_1_1dao_1_1sql__error.html" title="qx::dao::sql_error : define a SQL error exception and retrieve QSqlError type of Qt library...">qx::dao::sql_error</a>(<a class="code" href="_qx_repository_8h.html#af52e6f9587a7121705a3be3e5425bb27">QX_REPOSITORY_POINTER_DYNAMIC_CAST_ERROR</a>); }; <span class="keywordflow">return</span> t; } };
<a name="l00266"></a>00266 <span class="preprocessor">#else // _QX_NO_RTTI</span>
<a name="l00267"></a><a class="code" href="structqx_1_1_qx_repository_1_1qx_verify_pointer_3_01true_00_01dummy_01_4.html#afc74a84481fefde1743420609e1e23b0">00267</a> <span class="preprocessor"></span>   { <span class="keyword">static</span> <span class="keyword">inline</span> T * <span class="keyword">get</span>(QObject * p) { T * t = <span class="keyword">dynamic_cast&lt;</span>T *<span class="keyword">&gt;</span>(p); <span class="keywordflow">if</span> (! t) { <span class="keywordflow">throw</span> <a class="code" href="classqx_1_1dao_1_1sql__error.html" title="qx::dao::sql_error : define a SQL error exception and retrieve QSqlError type of Qt library...">qx::dao::sql_error</a>(<a class="code" href="_qx_repository_8h.html#af52e6f9587a7121705a3be3e5425bb27">QX_REPOSITORY_POINTER_DYNAMIC_CAST_ERROR</a>); }; <span class="keywordflow">return</span> t; } };
<a name="l00268"></a>00268 <span class="preprocessor">#endif // _QX_NO_RTTI</span>
<a name="l00269"></a>00269 <span class="preprocessor"></span>
<a name="l00270"></a>00270 <span class="keyword">public</span>:
<a name="l00271"></a>00271 
<a name="l00272"></a><a class="code" href="classqx_1_1_qx_repository.html#a1e9d1519a9eb9348895e72df8f9a55df">00272</a>    <span class="keyword">virtual</span> <span class="keywordtype">long</span> <a class="code" href="classqx_1_1_qx_repository.html#a1e9d1519a9eb9348895e72df8f9a55df">_count</a>(<span class="keyword">const</span> <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a> &amp; query = <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a>())
<a name="l00273"></a>00273    { <span class="keywordflow">return</span> this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#aaeaf116e22bb483dee412fa844688bfe">count</a>(query); }
<a name="l00274"></a>00274 
<a name="l00275"></a><a class="code" href="classqx_1_1_qx_repository.html#a4d881ea3a09541b65982ca910ef6e417">00275</a>    <span class="keyword">virtual</span> <span class="keywordtype">void</span> * <a class="code" href="classqx_1_1_qx_repository.html#a4d881ea3a09541b65982ca910ef6e417">_fetchById</a>(<span class="keyword">const</span> QVariant &amp; <span class="keywordtype">id</span>, <span class="keyword">const</span> QStringList &amp; columns = QStringList(), <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00276"></a>00276    { <span class="keywordflow">return</span> <span class="keyword">static_cast&lt;</span><span class="keywordtype">void</span> *<span class="keyword">&gt;</span>(this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a2a606e996bfa58f5d1af7e62104622ac">fetchById</a>(<span class="keywordtype">id</span>, columns, relation)); }
<a name="l00277"></a>00277 
<a name="l00278"></a><a class="code" href="classqx_1_1_qx_repository.html#a2388faad9563ddc4a3a367c897fea213">00278</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a4d881ea3a09541b65982ca910ef6e417">_fetchById</a>(QObject * p, <span class="keyword">const</span> QStringList &amp; columns = QStringList(), <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00279"></a>00279    {
<a name="l00280"></a>00280       T * t = <a class="code" href="structqx_1_1_qx_repository_1_1qx_verify_pointer.html">qxVerifyPointer&lt;boost::is_base_of&lt;QObject, T&gt;::value</a>, 0&gt;<a class="code" href="group___qx_cache.html#gaf467221c40ed6d8960109a8a00c3e3fa" title="Return the object of type T associated with key sKey, or return default instance of T() if the key do...">::get</a>(p);
<a name="l00281"></a>00281       <span class="keywordflow">return</span> this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a2a606e996bfa58f5d1af7e62104622ac">fetchById</a>((* t), columns, relation);
<a name="l00282"></a>00282    }
<a name="l00283"></a>00283 
<a name="l00284"></a><a class="code" href="classqx_1_1_qx_repository.html#ac907790bb85901ef2b8a79c85ad672f5">00284</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a4d881ea3a09541b65982ca910ef6e417">_fetchById</a>(<a class="code" href="classqx_1_1_ix_collection.html" title="qx::IxCollection : common interface for all QxOrm containers qx::QxCollection&lt;Key, Value&gt;">qx::IxCollection</a> * p, <span class="keyword">const</span> QStringList &amp; columns = QStringList(), <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00285"></a>00285    {
<a name="l00286"></a>00286       <a class="code" href="_qx_repository_8h.html#a09101357f58266c835562c64dc380ddd">QX_REPOSITORY_CAST_COLLECTION</a>
<a name="l00287"></a>00287       <span class="keywordflow">return</span> (x ? this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a2a606e996bfa58f5d1af7e62104622ac">fetchById</a>((* x), columns, relation) : this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a2a606e996bfa58f5d1af7e62104622ac">fetchById</a>((* y), columns, relation));
<a name="l00288"></a>00288    }
<a name="l00289"></a>00289 
<a name="l00290"></a><a class="code" href="classqx_1_1_qx_repository.html#af8111f1b296273fa3ffbcf60fc7687d8">00290</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#af8111f1b296273fa3ffbcf60fc7687d8">_fetchAll</a>(QObject * p, <span class="keyword">const</span> QStringList &amp; columns = QStringList(), <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00291"></a>00291    {
<a name="l00292"></a>00292       T * t = <a class="code" href="structqx_1_1_qx_repository_1_1qx_verify_pointer.html">qxVerifyPointer&lt;boost::is_base_of&lt;QObject, T&gt;::value</a>, 0&gt;<a class="code" href="group___qx_cache.html#gaf467221c40ed6d8960109a8a00c3e3fa" title="Return the object of type T associated with key sKey, or return default instance of T() if the key do...">::get</a>(p);
<a name="l00293"></a>00293       <span class="keywordflow">return</span> this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#aefbdf94ee25b218ae2a5cbc21977cf32">fetchAll</a>((* t), columns, relation);
<a name="l00294"></a>00294    }
<a name="l00295"></a>00295 
<a name="l00296"></a><a class="code" href="classqx_1_1_qx_repository.html#aa8ae00fe49bbf7834aa8525c6141ee53">00296</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#af8111f1b296273fa3ffbcf60fc7687d8">_fetchAll</a>(<a class="code" href="classqx_1_1_ix_collection.html" title="qx::IxCollection : common interface for all QxOrm containers qx::QxCollection&lt;Key, Value&gt;">qx::IxCollection</a> * p, <span class="keyword">const</span> QStringList &amp; columns = QStringList(), <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00297"></a>00297    {
<a name="l00298"></a>00298       <a class="code" href="_qx_repository_8h.html#a09101357f58266c835562c64dc380ddd">QX_REPOSITORY_CAST_COLLECTION</a>
<a name="l00299"></a>00299       <span class="keywordflow">return</span> (x ? this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#aefbdf94ee25b218ae2a5cbc21977cf32">fetchAll</a>((* x), columns, relation) : this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#aefbdf94ee25b218ae2a5cbc21977cf32">fetchAll</a>((* y), columns, relation));
<a name="l00300"></a>00300    }
<a name="l00301"></a>00301 
<a name="l00302"></a><a class="code" href="classqx_1_1_qx_repository.html#a40b1761becb6f8a4799ba122718a6fc4">00302</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a40b1761becb6f8a4799ba122718a6fc4">_fetchByQuery</a>(<span class="keyword">const</span> <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a> &amp; query, QObject * p, <span class="keyword">const</span> QStringList &amp; columns = QStringList(), <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00303"></a>00303    {
<a name="l00304"></a>00304       T * t = <a class="code" href="structqx_1_1_qx_repository_1_1qx_verify_pointer.html">qxVerifyPointer&lt;boost::is_base_of&lt;QObject, T&gt;::value</a>, 0&gt;<a class="code" href="group___qx_cache.html#gaf467221c40ed6d8960109a8a00c3e3fa" title="Return the object of type T associated with key sKey, or return default instance of T() if the key do...">::get</a>(p);
<a name="l00305"></a>00305       <span class="keywordflow">return</span> this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a887d3f3f555fca6d41442cc18fa786a9">fetchByQuery</a>(query, (* t), columns, relation);
<a name="l00306"></a>00306    }
<a name="l00307"></a>00307 
<a name="l00308"></a><a class="code" href="classqx_1_1_qx_repository.html#a0d61782c8a4789a0936cf27c8a0f93ba">00308</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a40b1761becb6f8a4799ba122718a6fc4">_fetchByQuery</a>(<span class="keyword">const</span> <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a> &amp; query, <a class="code" href="classqx_1_1_ix_collection.html" title="qx::IxCollection : common interface for all QxOrm containers qx::QxCollection&lt;Key, Value&gt;">qx::IxCollection</a> * p, <span class="keyword">const</span> QStringList &amp; columns = QStringList(), <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00309"></a>00309    {
<a name="l00310"></a>00310       <a class="code" href="_qx_repository_8h.html#a09101357f58266c835562c64dc380ddd">QX_REPOSITORY_CAST_COLLECTION</a>
<a name="l00311"></a>00311       <span class="keywordflow">return</span> (x ? this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a887d3f3f555fca6d41442cc18fa786a9">fetchByQuery</a>(query, (* x), columns, relation) : this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a887d3f3f555fca6d41442cc18fa786a9">fetchByQuery</a>(query, (* y), columns, relation));
<a name="l00312"></a>00312    }
<a name="l00313"></a>00313 
<a name="l00314"></a><a class="code" href="classqx_1_1_qx_repository.html#a3484dd147fd4f51b71c5f4e525220bf6">00314</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a3484dd147fd4f51b71c5f4e525220bf6">_insert</a>(QObject * p, <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00315"></a>00315    {
<a name="l00316"></a>00316       T * t = <a class="code" href="structqx_1_1_qx_repository_1_1qx_verify_pointer.html">qxVerifyPointer&lt;boost::is_base_of&lt;QObject, T&gt;::value</a>, 0&gt;<a class="code" href="group___qx_cache.html#gaf467221c40ed6d8960109a8a00c3e3fa" title="Return the object of type T associated with key sKey, or return default instance of T() if the key do...">::get</a>(p);
<a name="l00317"></a>00317       <span class="keywordflow">return</span> this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#ad2a39526df52bb5b02fc54f4d24798c7">insert</a>((* t), relation);
<a name="l00318"></a>00318    }
<a name="l00319"></a>00319 
<a name="l00320"></a><a class="code" href="classqx_1_1_qx_repository.html#aad9a79766ed06d11a884c4031b463810">00320</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a3484dd147fd4f51b71c5f4e525220bf6">_insert</a>(<a class="code" href="classqx_1_1_ix_collection.html" title="qx::IxCollection : common interface for all QxOrm containers qx::QxCollection&lt;Key, Value&gt;">qx::IxCollection</a> * p, <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00321"></a>00321    {
<a name="l00322"></a>00322       <a class="code" href="_qx_repository_8h.html#a09101357f58266c835562c64dc380ddd">QX_REPOSITORY_CAST_COLLECTION</a>
<a name="l00323"></a>00323       <span class="keywordflow">return</span> (x ? this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#ad2a39526df52bb5b02fc54f4d24798c7">insert</a>((* x), relation) : this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#ad2a39526df52bb5b02fc54f4d24798c7">insert</a>((* y), relation));
<a name="l00324"></a>00324    }
<a name="l00325"></a>00325 
<a name="l00326"></a><a class="code" href="classqx_1_1_qx_repository.html#a2773cee617161ceae4fac2760d173e64">00326</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a2773cee617161ceae4fac2760d173e64">_update</a>(QObject * p, <span class="keyword">const</span> <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a> &amp; query = <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a>(), <span class="keyword">const</span> QStringList &amp; columns = QStringList(), <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00327"></a>00327    {
<a name="l00328"></a>00328       T * t = <a class="code" href="structqx_1_1_qx_repository_1_1qx_verify_pointer.html">qxVerifyPointer&lt;boost::is_base_of&lt;QObject, T&gt;::value</a>, 0&gt;<a class="code" href="group___qx_cache.html#gaf467221c40ed6d8960109a8a00c3e3fa" title="Return the object of type T associated with key sKey, or return default instance of T() if the key do...">::get</a>(p);
<a name="l00329"></a>00329       <span class="keywordflow">return</span> this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a76aef40c870df4484a67e75134ea6aa0">update</a>((* t), query, columns, relation);
<a name="l00330"></a>00330    }
<a name="l00331"></a>00331 
<a name="l00332"></a><a class="code" href="classqx_1_1_qx_repository.html#a3fc0fd799291724871909f670d14dba7">00332</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a2773cee617161ceae4fac2760d173e64">_update</a>(<a class="code" href="classqx_1_1_ix_collection.html" title="qx::IxCollection : common interface for all QxOrm containers qx::QxCollection&lt;Key, Value&gt;">qx::IxCollection</a> * p, <span class="keyword">const</span> <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a> &amp; query = <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a>(), <span class="keyword">const</span> QStringList &amp; columns = QStringList(), <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00333"></a>00333    {
<a name="l00334"></a>00334       <a class="code" href="_qx_repository_8h.html#a09101357f58266c835562c64dc380ddd">QX_REPOSITORY_CAST_COLLECTION</a>
<a name="l00335"></a>00335       <span class="keywordflow">return</span> (x ? this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a76aef40c870df4484a67e75134ea6aa0">update</a>((* x), query, columns, relation) : this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a76aef40c870df4484a67e75134ea6aa0">update</a>((* y), query, columns, relation));
<a name="l00336"></a>00336    }
<a name="l00337"></a>00337 
<a name="l00338"></a><a class="code" href="classqx_1_1_qx_repository.html#a4ae68f73d431c85bbdce750dc4d98e13">00338</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a4ae68f73d431c85bbdce750dc4d98e13">_save</a>(QObject * p, <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00339"></a>00339    {
<a name="l00340"></a>00340       T * t = <a class="code" href="structqx_1_1_qx_repository_1_1qx_verify_pointer.html">qxVerifyPointer&lt;boost::is_base_of&lt;QObject, T&gt;::value</a>, 0&gt;<a class="code" href="group___qx_cache.html#gaf467221c40ed6d8960109a8a00c3e3fa" title="Return the object of type T associated with key sKey, or return default instance of T() if the key do...">::get</a>(p);
<a name="l00341"></a>00341       <span class="keywordflow">return</span> this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a85189ede9577d00a21a51b48c2bc5f7c">save</a>((* t), relation);
<a name="l00342"></a>00342    }
<a name="l00343"></a>00343 
<a name="l00344"></a><a class="code" href="classqx_1_1_qx_repository.html#ab45ffde7a1cb9ba1117a90231c626c15">00344</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a4ae68f73d431c85bbdce750dc4d98e13">_save</a>(<a class="code" href="classqx_1_1_ix_collection.html" title="qx::IxCollection : common interface for all QxOrm containers qx::QxCollection&lt;Key, Value&gt;">qx::IxCollection</a> * p, <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00345"></a>00345    {
<a name="l00346"></a>00346       <a class="code" href="_qx_repository_8h.html#a09101357f58266c835562c64dc380ddd">QX_REPOSITORY_CAST_COLLECTION</a>
<a name="l00347"></a>00347       <span class="keywordflow">return</span> (x ? this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a85189ede9577d00a21a51b48c2bc5f7c">save</a>((* x), relation) : this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a85189ede9577d00a21a51b48c2bc5f7c">save</a>((* y), relation));
<a name="l00348"></a>00348    }
<a name="l00349"></a>00349 
<a name="l00350"></a><a class="code" href="classqx_1_1_qx_repository.html#afecf5f5ea5de675cb9331ef837e4891a">00350</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#afecf5f5ea5de675cb9331ef837e4891a">_deleteById</a>(<span class="keyword">const</span> QVariant &amp; <span class="keywordtype">id</span>)
<a name="l00351"></a>00351    { <span class="keywordflow">return</span> this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a310fbb3908beebff59e61cc5dd5b92fa">deleteById</a>(<span class="keywordtype">id</span>); }
<a name="l00352"></a>00352 
<a name="l00353"></a><a class="code" href="classqx_1_1_qx_repository.html#ab8aa18f95b73814a8d0836f453962b48">00353</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#afecf5f5ea5de675cb9331ef837e4891a">_deleteById</a>(QObject * p)
<a name="l00354"></a>00354    {
<a name="l00355"></a>00355       T * t = <a class="code" href="structqx_1_1_qx_repository_1_1qx_verify_pointer.html">qxVerifyPointer&lt;boost::is_base_of&lt;QObject, T&gt;::value</a>, 0&gt;<a class="code" href="group___qx_cache.html#gaf467221c40ed6d8960109a8a00c3e3fa" title="Return the object of type T associated with key sKey, or return default instance of T() if the key do...">::get</a>(p);
<a name="l00356"></a>00356       <span class="keywordflow">return</span> this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a310fbb3908beebff59e61cc5dd5b92fa">deleteById</a>(* t);
<a name="l00357"></a>00357    }
<a name="l00358"></a>00358 
<a name="l00359"></a><a class="code" href="classqx_1_1_qx_repository.html#a81e5efaba3dde8a6a7c2d55380aa231a">00359</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#afecf5f5ea5de675cb9331ef837e4891a">_deleteById</a>(<a class="code" href="classqx_1_1_ix_collection.html" title="qx::IxCollection : common interface for all QxOrm containers qx::QxCollection&lt;Key, Value&gt;">qx::IxCollection</a> * p)
<a name="l00360"></a>00360    {
<a name="l00361"></a>00361       <a class="code" href="_qx_repository_8h.html#a09101357f58266c835562c64dc380ddd">QX_REPOSITORY_CAST_COLLECTION</a>
<a name="l00362"></a>00362       <span class="keywordflow">return</span> (x ? this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a310fbb3908beebff59e61cc5dd5b92fa">deleteById</a>(* x) : this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a310fbb3908beebff59e61cc5dd5b92fa">deleteById</a>(* y));
<a name="l00363"></a>00363    }
<a name="l00364"></a>00364 
<a name="l00365"></a><a class="code" href="classqx_1_1_qx_repository.html#ad888abb53e307d896ceece712f083142">00365</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#ad888abb53e307d896ceece712f083142">_deleteAll</a>()
<a name="l00366"></a>00366    { <span class="keywordflow">return</span> this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#af4af3fb73fa2d10ff47cc21d6a755e5b">deleteAll</a>(); }
<a name="l00367"></a>00367 
<a name="l00368"></a><a class="code" href="classqx_1_1_qx_repository.html#a087da4587f2ac6ceadad2db2007d27df">00368</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a087da4587f2ac6ceadad2db2007d27df">_deleteByQuery</a>(<span class="keyword">const</span> <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a> &amp; query)
<a name="l00369"></a>00369    { <span class="keywordflow">return</span> this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a5f8d83b11586eb7235601fc24905addb">deleteByQuery</a>(query); }
<a name="l00370"></a>00370 
<a name="l00371"></a><a class="code" href="classqx_1_1_qx_repository.html#a59a8387ff7948defc3b4441468559942">00371</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a59a8387ff7948defc3b4441468559942">_destroyById</a>(<span class="keyword">const</span> QVariant &amp; <span class="keywordtype">id</span>)
<a name="l00372"></a>00372    { <span class="keywordflow">return</span> this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#aa841e88f363fe8e6247d750727e8b89d">destroyById</a>(<span class="keywordtype">id</span>); }
<a name="l00373"></a>00373 
<a name="l00374"></a><a class="code" href="classqx_1_1_qx_repository.html#a964e2f2d35a713b178c7caab11238e4c">00374</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a59a8387ff7948defc3b4441468559942">_destroyById</a>(QObject * p)
<a name="l00375"></a>00375    {
<a name="l00376"></a>00376       T * t = <a class="code" href="structqx_1_1_qx_repository_1_1qx_verify_pointer.html">qxVerifyPointer&lt;boost::is_base_of&lt;QObject, T&gt;::value</a>, 0&gt;<a class="code" href="group___qx_cache.html#gaf467221c40ed6d8960109a8a00c3e3fa" title="Return the object of type T associated with key sKey, or return default instance of T() if the key do...">::get</a>(p);
<a name="l00377"></a>00377       <span class="keywordflow">return</span> this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#aa841e88f363fe8e6247d750727e8b89d">destroyById</a>(* t);
<a name="l00378"></a>00378    }
<a name="l00379"></a>00379 
<a name="l00380"></a><a class="code" href="classqx_1_1_qx_repository.html#ae91c32d9ce492ca28b26a95cb1e6af53">00380</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a59a8387ff7948defc3b4441468559942">_destroyById</a>(<a class="code" href="classqx_1_1_ix_collection.html" title="qx::IxCollection : common interface for all QxOrm containers qx::QxCollection&lt;Key, Value&gt;">qx::IxCollection</a> * p)
<a name="l00381"></a>00381    {
<a name="l00382"></a>00382       <a class="code" href="_qx_repository_8h.html#a09101357f58266c835562c64dc380ddd">QX_REPOSITORY_CAST_COLLECTION</a>
<a name="l00383"></a>00383       <span class="keywordflow">return</span> (x ? this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#aa841e88f363fe8e6247d750727e8b89d">destroyById</a>(* x) : this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#aa841e88f363fe8e6247d750727e8b89d">destroyById</a>(* y));
<a name="l00384"></a>00384    }
<a name="l00385"></a>00385 
<a name="l00386"></a><a class="code" href="classqx_1_1_qx_repository.html#a42bc1d58414f4b28ac934d9d49be3d5d">00386</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#a42bc1d58414f4b28ac934d9d49be3d5d">_destroyAll</a>()
<a name="l00387"></a>00387    { <span class="keywordflow">return</span> this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a7e1b18e3b6aabee7b1978b0bdd8bbe93">destroyAll</a>(); }
<a name="l00388"></a>00388 
<a name="l00389"></a><a class="code" href="classqx_1_1_qx_repository.html#afc0e5f02b0e018bc1c2e59dce1886820">00389</a>    <span class="keyword">virtual</span> QSqlError <a class="code" href="classqx_1_1_qx_repository.html#afc0e5f02b0e018bc1c2e59dce1886820">_destroyByQuery</a>(<span class="keyword">const</span> <a class="code" href="classqx_1_1_qx_sql_query.html" title="qx::QxSqlQuery : define a user SQL query added to default SQL query builded by QxOrm library...">qx::QxSqlQuery</a> &amp; query)
<a name="l00390"></a>00390    { <span class="keywordflow">return</span> this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#ad19da768437a00d0cc00f0ac4c7d9823">destroyByQuery</a>(query); }
<a name="l00391"></a>00391 
<a name="l00392"></a><a class="code" href="classqx_1_1_qx_repository.html#a00e44f675d2e729e77635b8fd4f8c23d">00392</a>    <span class="keyword">virtual</span> <a class="code" href="classqx_1_1_qx_bool.html" title="qx_bool : boolean type with code and description message when an error occured">qx_bool</a> <a class="code" href="classqx_1_1_qx_repository.html#a00e44f675d2e729e77635b8fd4f8c23d">_exist</a>(QObject * p)
<a name="l00393"></a>00393    {
<a name="l00394"></a>00394       T * t = <a class="code" href="structqx_1_1_qx_repository_1_1qx_verify_pointer.html">qxVerifyPointer&lt;boost::is_base_of&lt;QObject, T&gt;::value</a>, 0&gt;<a class="code" href="group___qx_cache.html#gaf467221c40ed6d8960109a8a00c3e3fa" title="Return the object of type T associated with key sKey, or return default instance of T() if the key do...">::get</a>(p);
<a name="l00395"></a>00395       <span class="keywordflow">return</span> this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a1bd74ee1ac371e5f0c7903d1534f6864">exist</a>(* t);
<a name="l00396"></a>00396    }
<a name="l00397"></a>00397 
<a name="l00398"></a><a class="code" href="classqx_1_1_qx_repository.html#ad5f7e8c5a77db0657f23d2c78c9db16f">00398</a>    <span class="keyword">virtual</span> <a class="code" href="classqx_1_1_qx_bool.html" title="qx_bool : boolean type with code and description message when an error occured">qx_bool</a> <a class="code" href="classqx_1_1_qx_repository.html#a00e44f675d2e729e77635b8fd4f8c23d">_exist</a>(<a class="code" href="classqx_1_1_ix_collection.html" title="qx::IxCollection : common interface for all QxOrm containers qx::QxCollection&lt;Key, Value&gt;">qx::IxCollection</a> * p)
<a name="l00399"></a>00399    {
<a name="l00400"></a>00400       <a class="code" href="_qx_repository_8h.html#a09101357f58266c835562c64dc380ddd">QX_REPOSITORY_CAST_COLLECTION</a>
<a name="l00401"></a>00401       <span class="keywordflow">return</span> (x ? this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a1bd74ee1ac371e5f0c7903d1534f6864">exist</a>(* x) : this-&gt;<a class="code" href="classqx_1_1_qx_repository.html#a1bd74ee1ac371e5f0c7903d1534f6864">exist</a>(* y));
<a name="l00402"></a>00402    }
<a name="l00403"></a>00403 
<a name="l00404"></a><a class="code" href="classqx_1_1_qx_repository.html#a159ee780258d352ce1297e34748615ce">00404</a>    <span class="keyword">virtual</span> <a class="code" href="namespaceqx.html#a8792a6513f37c4a4ba24a55dbabee03b">qx::IxCollection_ptr</a> <a class="code" href="classqx_1_1_qx_repository.html#a159ee780258d352ce1297e34748615ce">_newCollection</a>()<span class="keyword"> const</span>
<a name="l00405"></a>00405 <span class="keyword">   </span>{
<a name="l00406"></a>00406       <a class="code" href="namespaceqx.html#a8792a6513f37c4a4ba24a55dbabee03b">qx::IxCollection_ptr</a> lst;
<a name="l00407"></a>00407       lst.reset(<span class="keyword">new</span> <a class="code" href="classqx_1_1_qx_repository.html#abe161ac26ebe9c7cb4fa02175abf6081">type_collection_boost</a>());
<a name="l00408"></a>00408       <span class="keywordflow">return</span> lst;
<a name="l00409"></a>00409    }
<a name="l00410"></a>00410 
<a name="l00411"></a><a class="code" href="classqx_1_1_qx_repository.html#a369043f156158555f3540c219c3a3c09">00411</a>    <span class="keyword">virtual</span> <a class="code" href="classqx_1_1_ix_class.html" title="qx::IxClass : common interface for all classes registered into QxOrm context">qx::IxClass</a> * <a class="code" href="classqx_1_1_qx_repository.html#a369043f156158555f3540c219c3a3c09">_getClass</a>()<span class="keyword"> const</span>
<a name="l00412"></a>00412 <span class="keyword">   </span>{ <span class="keywordflow">return</span> <a class="code" href="classqx_1_1_qx_class.html" title="qx::QxClass&lt;T&gt; : concrete class of type T registered into QxOrm context (this class is a singleton an...">qx::QxClass&lt;T&gt;::getSingleton</a>(); }
<a name="l00413"></a>00413 
<a name="l00414"></a>00414 <span class="keyword">public</span>:
<a name="l00415"></a>00415 
<a name="l00416"></a><a class="code" href="classqx_1_1_qx_repository.html#ac24b8248487889d68d9bf7ff1b373161">00416</a>    <span class="keyword">static</span> T * <a class="code" href="classqx_1_1_qx_repository.html#ac24b8248487889d68d9bf7ff1b373161">getById</a>(<span class="keyword">const</span> QVariant &amp; <span class="keywordtype">id</span>, <span class="keyword">const</span> QStringList &amp; columns = QStringList(), <span class="keyword">const</span> QStringList &amp; relation = QStringList())
<a name="l00417"></a>00417    {
<a name="l00418"></a>00418       <a class="code" href="classqx_1_1_ix_data_member_x.html" title="qx::IxDataMemberX : common interface for a list of IxDataMember class properties registered into QxOr...">IxDataMemberX</a> * pDataMemberX = <a class="code" href="classqx_1_1_qx_class.html" title="qx::QxClass&lt;T&gt; : concrete class of type T registered into QxOrm context (this class is a singleton an...">QxClass&lt;T&gt;::getSingleton</a>()-&gt;<a class="code" href="classqx_1_1_ix_class.html#a668a6091e56a8133606e64cba430baa4">getDataMemberX</a>();
<a name="l00419"></a>00419       <a class="code" href="classqx_1_1_ix_data_member.html" title="qx::IxDataMember : common interface for all class properties registered into QxOrm context...">IxDataMember</a> * pDataMemberId = (pDataMemberX ? pDataMemberX-&gt;<a class="code" href="classqx_1_1_ix_data_member_x.html#ada28538e61c5fd9bf352abdb325be6b0">getId_WithDaoStrategy</a>() : NULL);
<a name="l00420"></a>00420       <span class="keywordflow">if</span> (! pDataMemberId) { <a class="code" href="_qx_macro_8h.html#a70ab6c4ed8eb3e23107f171e0b41d612">qAssert</a>(<span class="keyword">false</span>); <span class="keywordflow">return</span> NULL; }
<a name="l00421"></a>00421       T * t = <span class="keyword">new</span> T(); QSqlError err;
<a name="l00422"></a>00422       pDataMemberId-&gt;<a class="code" href="classqx_1_1_ix_data_member.html#ab745b2a043797eecfe769c3f51257a35">fromVariant</a>(t, <span class="keywordtype">id</span>, -1, <a class="code" href="structqx_1_1cvt_1_1context.html#ade79c85929462745a3adcdf310c91a93a5fe28c5356333a6d2633c93cbd6e48e5">qx::cvt::context::e_database</a>);
<a name="l00423"></a>00423       <span class="keywordflow">if</span> (relation.count() == 0) { err = <a class="code" href="group___qx_dao.html#ga2abaf5f2e6de160b099cf2ab74967244" title="Fetch an object t (retrieve all its properties) of type T (registered into QxOrm context) mapped to a...">qx::dao::fetch_by_id</a>((* t), NULL, columns); }
<a name="l00424"></a>00424       <span class="keywordflow">else</span> { err = <a class="code" href="group___qx_dao.html#ga37648a23475371e1b83ea2082265790d" title="Fetch an object t (retrieve all its properties) of type T (registered into QxOrm context) mapped to a...">qx::dao::fetch_by_id_with_relation</a>(relation, (* t), NULL); }
<a name="l00425"></a>00425       <span class="keywordflow">if</span> (err.isValid()) { <span class="keyword">delete</span> t; t = NULL; }
<a name="l00426"></a>00426       <span class="keywordflow">return</span> t;
<a name="l00427"></a>00427    }
<a name="l00428"></a>00428 
<a name="l00429"></a>00429 };
<a name="l00430"></a>00430 
<a name="l00431"></a>00431 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
<a name="l00432"></a><a class="code" href="namespaceqx.html#a10d662c78d56271d8fdaeff896548e46">00432</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="namespaceqx.html#a10d662c78d56271d8fdaeff896548e46">register_repository</a>(<span class="keyword">const</span> QString &amp; sKey)
<a name="l00433"></a>00433 {
<a name="l00434"></a>00434    <span class="comment">// &#39;pNewRepository&#39; instance will be destroyed by &#39;qx::QxRepositoryX::unregisterRepository()&#39; method</span>
<a name="l00435"></a>00435    <a class="code" href="classqx_1_1_qx_repository.html" title="qx::QxRepository&lt;T&gt; : repository to provide a common interface to communicate with database...">qx::QxRepository&lt;T&gt;</a> * pNewRepository = <span class="keyword">new</span> <a class="code" href="classqx_1_1_qx_repository.html" title="qx::QxRepository&lt;T&gt; : repository to provide a common interface to communicate with database...">qx::QxRepository&lt;T&gt;</a>(sKey);
<a name="l00436"></a>00436    Q_UNUSED(pNewRepository);
<a name="l00437"></a>00437 }
<a name="l00438"></a>00438 
<a name="l00439"></a>00439 } <span class="comment">// namespace qx</span>
<a name="l00440"></a>00440 
<a name="l00441"></a>00441 <span class="preprocessor">#endif // _QX_REPOSITORY_H_</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="_qx_repository_8h.html">QxRepository.h</a>      </li>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>


    <li class="footer">Generated on Sun Dec 11 2016 13:41:03 for QxOrm by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
